(()=>{"use strict";const e=function(e,n){"string"==typeof e&&void 0!==window.newrelic&&"function"==typeof window.newrelic.addPageAction&&(n=n||{},newrelic.addPageAction(e,n))};let n={},t=null,o=null,i=null,a={},r=!1,d=new RegExp("(?:^|;\\s*)"+"X-ClientInfo".replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(document.cookie),c=!1,w=!1,l=!1;const s="LCP",u="FCP";function m(e,n,a){e&&(t=Object.assign({},t,e)),!i&&n&&"string"==typeof n&&(i=n),a&&"string"==typeof a&&(o=a)}function g(){return(d&&r||!d&&w)&&(n[u]||n[s])&&(o||window.dreckInfoData?.pageview_id||window.ShifuConfig?.pageview_id)&&l&&!c}function f(e){e&&(n=Object.assign({},n,e),l=!0),g()&&p()}function p(){c=!0,l=!1,t&&t.domElementsCount||(t=Object.assign({},t,{domElementsCount:document.querySelectorAll("*").length.toString()}));let r=function(){let e={};for(const t of Object.keys(n))a.hasOwnProperty(t)||(e[t]=n[t]);return e}();Object.keys(r).length>0?function(n){const r=o||window.dreckInfoData?.pageview_id,d=i||window.dreckInfoData?.flow+"-"+r;if(r&&d){let o={data:t,durations:n,uow:d,pageview_id:r};try{fetch("/hermes-service/topic/shopping_timmings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}).then((function(t){t.ok?a=Object.assign({},a,n):(e("DRECK_TIMMING",{type:"error",error:"TRACK_FETCH_NOT_OK",locale:window.locale,userAgent:navigator.userAgent,xClient:window.dreckInfoData&&window.dreckInfoData.x_client,pv:r,uow:d}),console.warn("Error sending timmings",t))})).catch((function(n){e("DRECK_TIMMING",{type:"error",error:"TRACK_CATCH_FETCH_ERROR",locale:window.locale,userAgent:navigator.userAgent,xClient:window.dreckInfoData&&window.dreckInfoData.x_client,pv:r,uow:d,detail:n?.message||n,request:o})})).finally((()=>{c=!1,l&&p()}))}catch(n){e("DRECK_TIMMING",{type:"error",error:"TRACK_CATCH_ERROR",locale:window.locale,userAgent:navigator.userAgent,xClient:window.dreckInfoData&&window.dreckInfoData.x_client,pv:r,uow:d}),c=!1,l&&p()}}else e("DRECK_TIMMING",{type:"error",error:"TRACK_WITHOUT_PV",locale:window.locale,userAgent:navigator.userAgent,xClient:window.dreckInfoData&&window.dreckInfoData.x_client,pv:r,uow:d}),console.warn("Error sending timmings: pageViewId or uow not found"),c=!1,l&&p()}(r):c=!1}window.customTimmings={},window.customTimmings.trackTimmings=(e,n,t,o)=>{if(!(e&&e.length>0))return null;let i={};for(let n=0;n{let i=o||Math.round(window.performance.now());if(window&&window.location&&window.location.search){const e=new Proxy(new URLSearchParams(window.location.search),{get:(e,n)=>e.get(n)});if(e&&e.tp){let n=e.tp;n=JSON.parse(atob(n));const t=performance.timeOrigin||performance.timing.navigationStart,o=performance.now();i=Math.round(t-n.Ins+o)}}m(e,n,t),f({"main-feature":i})},window.customTimmings.trackBounce=(e,n,t,o)=>{m(e,n,t),f({"bounce-time":o||Math.round(window.performance.now())})},document.addEventListener("apptimes.complete",(function(n){try{n.detail&&(n.detail.data&&(t=Object.assign({},t,n.detail.data)),t&&t.uow&&(i=t.uow),n.detail.times&&(r=!0,f(n.detail.times)))}catch(n){e("DRECK_TIMMING",{type:"error",error:"TIMES_COMPLETE_ERROR",locale:window.locale,userAgent:navigator.userAgent,xClient:window.dreckInfoData&&window.dreckInfoData.x_client})}})),document.addEventListener("webVitalsReady",(function(e){if(e.detail&&(e.detail.LCP||e.detail.FCP)){let n={};e.detail.FCP&&(n[u]=e.detail.FCP),e.detail.LCP&&(n[s]=e.detail.LCP),f(n)}})),window.addEventListener("load",(()=>{w||(w=!0,document.dispatchEvent(new CustomEvent("apptimes")),window.addWebVitals?window.addWebVitals():document.addEventListener("webVitalsReadyToUse",window.addWebVitals),window.dreckInfoData?.updateDone?f():document.addEventListener("updateDreck.complete",f))}))})();